<?php


namespace App\Http\Controllers\Mini\Shop;

use App\Http\Controllers\Controller;
use App\Services\IntegralLogService;

/**
 * Class IntegralController
 * @package App\Http\Controllers\Mini\Shop
 * 2021/3/15 - 23:05
 * Administrator
 * 积分控制器
 */
class IntegralController extends Controller
{
    // 积分日志服务
    public $IntegralService;

    /**
     * IntegralController constructor.
     */
    public function __construct()
    {
        $this->IntegralService = new IntegralLogService();
    }


    /**
     * 2021/3/15--23:06
     * @author:董宗澳
     * @email:2453611300
     * @wechat:DZA74941
     * @QQ:2453611300
     * @web:www.quzha.net
     * @method:getList
     * @effect:获取积分日志 列表
     */
    public function getList()
    {
        try {
            $list = $this->IntegralService->getLogList(false);
            return $this->format($list, '获取成功');
        } catch (\Exception $e) {
            return $this->format_error('获取失败' . $e->getMessage());
        }
    }

    /**
     * 2021/3/15--23:06
     * @author:董宗澳
     * @email:2453611300
     * @wechat:DZA74941
     * @QQ:2453611300
     * @web:www.quzha.net
     * @method:getInfo
     * @effect:积分日志详情
     */
    public function getInfo()
    {
        try {
            $id = request()->id;
            $info = $this->IntegralService->getLogInfo($id);
            return $this->format($info, '获取成功');
        } catch (\Exception $e) {
            return $this->format_error('获取失败');
        }

    }


    /**
     * 积分日志
     */
    public function __destruct()
    {
        $this->IntegralService;
        // TODO: Implement __destruct() method.
    }


}
